********************************************************************************
********************************************************************************
* to obtain the dataset 
*	1) with fips attached
*	2) append all emission sources
********************************************************************************
********************************************************************************
clear all
version 11
set more off

global root "~\APEEP_2008\results"
cd $root


****************************
* attach fips with e - area
****************************
insheet using .\APEEP_results_output\2008_PM_E_A.csv, nonames comma clear
ren v1 e_nh3
ren v2 e_pm25
ren v3 e_nox
ren v4 e_so2
ren v5 e_voc

gen fips_running=_n
merge 1:1 fips_running using .\Stata_working\data_fips_for_merge
ren a fips
keep e_nh3- fips_running fips

compress
saveold .\Stata_working\data_e_with_fips_area, version(11) replace


****************************
* attach fips with e - low
****************************
insheet using .\APEEP_results_output\2008_PM_E_L.csv, nonames comma clear
ren v1 e_nh3
ren v2 e_pm25
ren v3 e_nox
ren v4 e_so2
ren v5 e_voc

gen fips_running=_n
merge 1:1 fips_running using .\Stata_working\data_fips_for_merge
ren l fips
keep e_nh3- fips_running fips

compress
saveold .\Stata_working\data_e_with_fips_low, version(11) replace


****************************
* attach fips with e - med
****************************
insheet using .\APEEP_results_output\2008_PM_E_M.csv, nonames comma clear
ren v1 e_nh3
ren v2 e_pm25
ren v3 e_nox
ren v4 e_so2
ren v5 e_voc

gen fips_running=_n
merge 1:1 fips_running using .\Stata_working\data_fips_for_merge
ren m fips
keep e_nh3- fips_running fips

compress
saveold .\Stata_working\data_e_with_fips_med, version(11) replace


****************************
* attach fips with e - T1
****************************
insheet using .\APEEP_results_output\2008_PM_E_T1.csv, nonames comma clear
ren v1 e_nh3
ren v2 e_pm25
ren v3 e_nox
ren v4 e_so2
ren v5 e_voc

gen fips_running=_n
merge 1:1 fips_running using .\Stata_working\data_fips_for_merge
ren t1 fips
keep e_nh3- fips_running fips
drop if fips==.

compress
saveold .\Stata_working\data_e_with_fips_t1, version(11) replace


****************************
* attach fips with e - T2
****************************
insheet using .\APEEP_results_output\2008_PM_E_T2.csv, nonames comma clear
ren v1 e_nh3
ren v2 e_pm25
ren v3 e_nox
ren v4 e_so2
ren v5 e_voc

gen fips_running=_n
merge 1:1 fips_running using .\Stata_working\data_fips_for_merge
ren t2 fips
keep e_nh3- fips_running fips
drop if fips==.

compress
saveold .\Stata_working\data_e_with_fips_t2, version(11) replace


****************************
* append all the datasets
****************************
use .\Stata_working\data_e_with_fips_area, clear
append using .\Stata_working\data_e_with_fips_low ///
			 .\Stata_working\data_e_with_fips_med ///
			 .\Stata_working\data_e_with_fips_t1 ///
			 .\Stata_working\data_e_with_fips_t2, nolabel
*
gen apeep_results_running=_n
ren fips fips_e

compress
saveold .\Stata_working\data_e_with_fips_all_appended, version(11) replace


	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	